import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:oi_ai_tool/common/IconFontIcons.dart';
import 'package:oi_ai_tool/config/setting_view_config.dart';
import 'package:oi_ai_tool/widgets/oi_appbar.dart';

class OiSetting extends StatefulWidget {
  const OiSetting({super.key});

  @override
  State<OiSetting> createState() => _OiSetting();
}

class _OiSetting extends State<OiSetting> {
  listItem(
      {String title = "",
      IconData iconData = Icons.add,
      GestureTapCallback? onTap}) {
    return Container(
        // height: 40.h,
        margin: EdgeInsets.only(bottom: 8.dm),
        decoration: const BoxDecoration(
          color: Colors.white,
        ),
        child: ListTile(
          // contentPadding: EdgeInsets.zero,
          onFocusChange: (isfocus) {},
          // focusColor: Colors.amber,
          hoverColor: Colors.cyan,
          titleAlignment: ListTileTitleAlignment.center,
          title: Text(title),
          leading: Icon(iconData),
          trailing: const Icon(IconFontIcons.iconArrow),
          onTap: onTap,
        ));
  }

  listView() {
    List<Widget> listData = [];
    for (var item in SettingViewConfig.settingList) {
      listData.add(listItem(
          title: item['title'], iconData: item['icon'], onTap: item['onTap']));
    }
    return listData;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: OiAppbar(),
      body: Container(
        padding: EdgeInsets.only(top: 10.sp),
        width: double.infinity,
        child: ListView(
          children: listView(),
        ),
      ),
    );
  }
}
